package cn.zeal4j.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author Administrator
 * @file IntelliJ IDEA Spring-Security-Tutorial
 * @create 2020 09 27 22:35
 */
@Controller
public class LoginController {

    @RequestMapping("csrf-login.page")
    public String toCsrfLoginPage() {
        return "csrf-login";
    }

    @RequestMapping("main.page")
    public String toMainPage() {
        return "main"; // 模版内的页面不允许重定向，忘了忘了
    }

    @PostMapping("error.page") // 控制器不支持POST请求跳转解析, 需要控制器跳转 Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
    public String redirectToErrorPage() {
        return "redirect:/error.html"; // 重定向要写/标识 区分模版解析
    }

}
